﻿using CoreShop.App.Units;
using CoreShop.Library;
using CoreShop.Model;
using CoreShop.Services;
using CoreShop.Services.Services.Report;
using SqlSugar;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Windows.Forms;
using static CoreShop.Library.GlobalEnumVars;
using static System.Runtime.CompilerServices.RuntimeHelpers;

namespace CoreShop.App
{
    public partial class frmSystemLog : UIForm
    {
        public bool returnValue;

        List<corecmsprinttasklog> lstSource = new List<corecmsprinttasklog>();
        public delegate void CloseFormPage(int pageIndex);
        public int mPageIndex = 0;
        public string number = "";

        long foodTypeId = 0;
        string foodTypeName = "";
        public frmSystemLog()
        {
            InitializeComponent();
        }

        #region 加载信息列表
        private void LoadDataList()
        {
            DateTime startDate = CommFunc.ConvertToDateTime(dateTimeRange.DateTimeStar);
            DateTime endDate = CommFunc.ConvertToDateTime(dateTimeRange.DateTimeEnd);
            int count = 0;
            var where = Expressionable.Create<corecmsprinttasklog>();
            where = where.And(p => p.createTime >= startDate && p.createTime <= endDate);
            lstSource = new corecmsprinttasklogServices().QueryPageAsync(ref count, mPageIndex, btnPg.PageSize, where);
            btnPg.TotalCount = count;
            this.binDetail.DataSource = lstSource;
            this.dgvPayList.AutoGenerateColumns = false;
        }

        #endregion
        private void Food_Load(object sender, System.EventArgs e)
        {
            mPageIndex = 1;
            dateTimeRange.DateTimeStar = CommFunc.ConvertToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00").ToString("yyyy-MM-dd HH:mm:ss");
            dateTimeRange.DateTimeEnd = CommFunc.ConvertToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59").ToString("yyyy-MM-dd HH:mm:ss");
            LoadDataList();
        }
        private void btnSerach_Click(object sender, EventArgs e)
        {
            mPageIndex = 1;
            LoadDataList();
        }

        private void dgvFoodList_CellDoubleClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {

        }

        private void btnPg_PageChanged(object sender, object pagingSource, int pageIndex, int count)
        {
            mPageIndex = pageIndex;
            LoadDataList();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void dgvPayList_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvPayList.SelectedRows.Count == 1)
            {
                rtxDataLog.Text = CommFunc.ConvertToString(dgvPayList.SelectedRows[0].Cells["message"].Value);
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}